<?php
$opt = getopt('h:p:');

$conf = '';
include 'db.php';
include 'env/env.php';
include 'env/consume.php';
if(isset($opt['h'])){
    $conf['server']['host'] = $opt['h'];
}
if(isset($opt['p'])){
    $conf['server']['port'] = $opt['p'];
}
define('DIR', __DIR__);
define('APP_NAME', 'consume');
// 引入主类
require_once 'lib/SwooleServer.php';

class ConsumeSwooleServer extends SwooleServer{
    public function onWorkerStart($server, $workerId)
    {
        $this->setProcessName('Worker_' . $workerId);
        require_once $this->rootDir . '/vendor/autoload.php';
        $baseWorker = new \Tyrone\Lib\ConsumeWorker();
        $baseWorker->init($server, $workerId, $this->config);
    }
}

// 绑定到当前对象

// 创建服务器实例并启动
$server = new ConsumeSwooleServer($conf);
$server->start();